package com.jn.mvvm2.views;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jn.mvvm2.R;
import com.jn.mvvm2.adapter.QAndAAdapter;
import com.jn.mvvm2.base.BaseActivity;
import com.jn.mvvm2.dao.QAndADao;
import com.jn.mvvm2.databinding.ActivityQandaListBinding;
import com.jn.mvvm2.entity.QAndAEntity;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.AndroidEntryPoint;

@AndroidEntryPoint // 允许 Hilt 注入依赖
public class QAndAListActivity extends BaseActivity<ActivityQandaListBinding> {
    private List<QAndAEntity> mList;
    private QAndAAdapter mAdapter;
    @Inject
    QAndADao qAndADao;

    @Override
    public int getLayoutId() {
        return R.layout.activity_qanda_list;
    }

    @Override
    public void init() {

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        mBinding.recyclerView.setLayoutManager(linearLayoutManager);
        mList = qAndADao.getAll();
        mAdapter = new QAndAAdapter(mList);
        mBinding.recyclerView.setAdapter(mAdapter);
    }

}